<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Tom的博客">
    <meta name="keyword"  content="">
    <link rel="shortcut icon" href="/img/favicon.ico">

    <title>
        
        Linux模糊搜索神器fzf终极配置 - Tom的博客
        
    </title>

    <!-- Custom CSS -->
    
<link rel="stylesheet" href="/css/aircloud.css">

    
<link rel="stylesheet" href="/css/gitment.css">

    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_pl6z7sid89qkt9.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
<meta name="generator" content="Hexo 5.4.0"></head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> 间歇性壮志凌云, 持续性混吃等死 </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>Tom</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/archives">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li >
                <a href="/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
        <div id="toc" class="toc-article">
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-text">安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE"><span class="toc-text">配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8"><span class="toc-text">使用</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%BB%88%E7%AB%AF%E4%B8%AD%E4%BD%BF%E7%94%A8"><span class="toc-text">终端中使用</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9C%A8vim%E4%B8%AD%E4%BD%BF%E7%94%A8"><span class="toc-text">在vim中使用</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%92%8Cranger%E9%85%8D%E5%90%88%E4%BD%BF%E7%94%A8"><span class="toc-text">和ranger配合使用</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3"><span class="toc-text">问题解决</span></a></li></ol>
</div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> 间歇性壮志凌云, 持续性混吃等死 </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        


<div class="post-container">
    <div class="post-title">
        Linux模糊搜索神器fzf终极配置
    </div>

    <div class="post-meta">
        <span class="attr">发布于：<span>2020-01-12 17:53:54</span></span>
        
        <span class="attr">标签：/
        
        <a class="tag" href="/tags/#fzf linux" title="fzf linux">fzf linux</a>
        <span>/</span>
        
        
        </span>
        <span class="attr">访问：<span id="busuanzi_value_page_pv"></span>
</span>
</span>
    </div>
    <div class="post-content no-indent">
        <p>fzf是Linux终端下的一款模糊搜索神器，速度极快，还可以配合vim以及其他软件使用，可以说是终端党的必备神器。虽然它安装起来比较简单，但是想要使用得比较好，还是需要一番配置的，但是我看网上配置的文章都写得比较简单，所以写这篇文章记录一下。</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p>fzf可以单独安装，不过我推荐在vim中和fzf.vim一起安装，比较方便而且简单,我使用的vim plug管理插件，所以在vim配置文件里添加以下两行就可以了。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Plug &#x27;junegunn/fzf&#x27;, &#123; &#x27;dir&#x27;: &#x27;~/.fzf&#x27;, &#x27;do&#x27;: &#x27;./install --all&#x27;  &#125;</span><br><span class="line">Plug &#x27;junegunn/fzf.vim&#x27;</span><br></pre></td></tr></table></figure>
<p>然后在vim下执行<code>:PlugInstall</code>，它就开始安装了，安装过程中会问你几个问题，都按y就好了。</p>
<p>安装完成后就可以开始使用了，但是现在使用起来并不是很爽，因为没有预览，不能搜索隐藏文件，而且只能搜索当前目录，还不能排除一些乱七八糟的文件夹，经过配置之后这些都可以解决。</p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><p>在使用之前首先要安装两个软件，fdfind（也有可能叫fd）和rg（ripgrep）还有 <a target="_blank" rel="noopener" href="https://github.com/sharkdp/bat">bat</a>（一个文本预览工具，类似于cat，但是比它更强大）。然后在<code>.zshrc</code>文件下添加以下设置。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"><span class="comment">##</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment">##FZF</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="comment">##</span></span></span><br><span class="line">[ -f ~/.fzf.zsh ] &amp;&amp; source ~/.fzf.zsh</span><br><span class="line"></span><br><span class="line">export FZF_DEFAULT_COMMAND=&#x27;fdfind --hidden --follow -E &quot;.git&quot; -E &quot;node_modules&quot; . /etc /home&#x27;</span><br><span class="line">export FZF_DEFAULT_OPTS=&#x27;--height 90% --layout=reverse --bind=alt-j:down,alt-k:up,alt-i:toggle+down --border --preview &quot;echo &#123;&#125; | ~/linux-config-file/fzf/fzf_preview.py&quot; --preview-window=down&#x27;</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> use fzf <span class="keyword">in</span> bash and zsh</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Use ~~ as the trigger sequence instead of the default **</span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="built_in">export</span> FZF_COMPLETION_TRIGGER=<span class="string">&#x27;~~&#x27;</span></span></span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Options to fzf <span class="built_in">command</span></span></span><br><span class="line"><span class="meta">#</span><span class="bash"><span class="built_in">export</span> FZF_COMPLETION_OPTS=<span class="string">&#x27;&#x27;</span></span></span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Use fd (https://github.com/sharkdp/fd) instead of the default find</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> <span class="built_in">command</span> <span class="keyword">for</span> listing path candidates.</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> - The first argument to the <span class="keyword">function</span> (<span class="variable">$1</span>) is the base path to start traversal</span></span><br><span class="line"><span class="meta">#</span><span class="bash"> - See the <span class="built_in">source</span> code (completion.&#123;bash,zsh&#125;) <span class="keyword">for</span> the details.</span></span><br><span class="line">_fzf_compgen_path() &#123;</span><br><span class="line">  fdfind --hidden --follow -E &quot;.git&quot; -E &quot;node_modules&quot; . /etc /home</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> Use fd to generate the list <span class="keyword">for</span> directory completion</span></span><br><span class="line">_fzf_compgen_dir() &#123;</span><br><span class="line">  fdfind --type d --hidden --follow -E &quot;.git&quot; -E &quot;node_modules&quot; . /etc /home</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<ul>
<li>前面有#号的是注释</li>
<li>FZF_DEFAULT_COMMAND是用来列出文件以供fzf搜索的命令</li>
<li>—hidden：允许搜索隐藏文件</li>
<li>-E：后面跟的目录不会被搜索，用来排除一些没什么用的目录</li>
<li>最后的/etc和/home就是会在这两个目录里进行搜索，你也可以添加其它目录</li>
<li>FZF_COMPLETION_OPTS是fzf搜索时的默认参数</li>
<li>—height：搜索窗口占屏幕的比例</li>
<li>—layout=reverse：默认搜索栏在底部，设置后搜索栏在上面</li>
<li>—bind：用来更改默认快捷键的，格式就是 快捷键:动作 设置之间用逗号分隔</li>
<li>—preview：预览命令，后面的python文件是我自己写的Python脚本路径，可以实现一些文件的预览</li>
<li>—preview-window：预览窗口的位置，默认在右边，我设置到下边</li>
<li>FZF_COMPLETION_TRIGGER：在终端触发fzf的快捷键，默认是**</li>
<li>最下面两个命令就是终端使用的时候的列出文件的命令，其实和上面的是一样的，只是下面的那个是只列出文件夹，所以多了一个—type参数</li>
</ul>
<p>下面是我自己写的预览脚本的内容，你得把它复制到文件里，授予执行权限，放到合适的路径，然后用你的路径替换上面我的路径，大佬请忽略我乱七八糟的语法和谜一般的命名。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#! /usr/bin/python3</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fzf_preview</span>(<span class="params">rg_name</span>):</span></span><br><span class="line">    rg_list = rg_name.split(<span class="string">&#x27;:&#x27;</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">len</span>(rg_list) == <span class="number">1</span>:</span><br><span class="line">        bat_range = <span class="number">0</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        bat_range = rg_list[<span class="number">1</span>].replace(<span class="string">&#x27;\n&#x27;</span>, <span class="string">&#x27;&#x27;</span>)</span><br><span class="line">    file_path_list = rg_list[<span class="number">0</span>].replace(<span class="string">&#x27;\n&#x27;</span>, <span class="string">&#x27;&#x27;</span>).split(<span class="string">&#x27;/&#x27;</span>)</span><br><span class="line">    <span class="keyword">for</span> i,filep <span class="keyword">in</span> <span class="built_in">zip</span>(<span class="built_in">range</span>(<span class="built_in">len</span>(file_path_list)), file_path_list):</span><br><span class="line">        path_space = filep.find(<span class="string">&#x27; &#x27;</span>)</span><br><span class="line">        <span class="keyword">if</span> <span class="keyword">not</span> path_space == -<span class="number">1</span>:</span><br><span class="line">            file_path_list[i] = <span class="string">&quot;&#x27;&#123;&#125;&#x27;&quot;</span>.<span class="built_in">format</span>(filep)</span><br><span class="line">        file_path = <span class="string">&#x27;/&#x27;</span>.join(file_path_list)</span><br><span class="line">    preview_nameandline = [file_path, bat_range]</span><br><span class="line">    <span class="keyword">return</span> preview_nameandline</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">&quot;__main__&quot;</span>:</span><br><span class="line">    rg_name = sys.stdin.readlines()[<span class="number">0</span>]</span><br><span class="line">    preview_nameandline = fzf_preview(rg_name)</span><br><span class="line">    <span class="keyword">if</span> os.path.isdir(preview_nameandline[<span class="number">0</span>]):</span><br><span class="line">        os.system(<span class="string">&#x27;ls -la &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(preview_nameandline[<span class="number">0</span>]))</span><br><span class="line">    <span class="keyword">elif</span> preview_nameandline[<span class="number">0</span>].replace(<span class="string">&quot;&#x27;&quot;</span>, <span class="string">&#x27;&#x27;</span>).endswith((<span class="string">&#x27;.zip&#x27;</span>, <span class="string">&#x27;.ZIP&#x27;</span>)):</span><br><span class="line">        os.system(<span class="string">&#x27;unzip -l &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(preview_nameandline[<span class="number">0</span>]))</span><br><span class="line">    <span class="keyword">elif</span> preview_nameandline[<span class="number">0</span>].replace(<span class="string">&quot;&#x27;&quot;</span>, <span class="string">&#x27;&#x27;</span>).endswith((<span class="string">&#x27;.rar&#x27;</span>, <span class="string">&#x27;.RAR&#x27;</span>)):</span><br><span class="line">        os.system(<span class="string">&#x27;unrar l &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(preview_nameandline[<span class="number">0</span>]))</span><br><span class="line">    <span class="keyword">elif</span> preview_nameandline[<span class="number">0</span>].replace(<span class="string">&quot;&#x27;&quot;</span>, <span class="string">&#x27;&#x27;</span>).endswith(<span class="string">&#x27;.torrent&#x27;</span>):</span><br><span class="line">        os.system(<span class="string">&#x27;transmission-show &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(preview_nameandline[<span class="number">0</span>]))</span><br><span class="line">    <span class="keyword">elif</span> preview_nameandline[<span class="number">0</span>].replace(<span class="string">&quot;&#x27;&quot;</span>, <span class="string">&#x27;&#x27;</span>).endswith((<span class="string">&#x27;.html&#x27;</span>, <span class="string">&#x27;.htm&#x27;</span>, <span class="string">&#x27;.xhtml&#x27;</span>)):</span><br><span class="line">        os.system(<span class="string">&#x27;w3m -dump &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(preview_nameandline[<span class="number">0</span>]))</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        os.system(<span class="string">&#x27;bat --style=numbers --color=always -r &#123;&#125;: &#123;&#125;&#x27;</span>.<span class="built_in">format</span>(</span><br><span class="line">            preview_nameandline[<span class="number">1</span>], preview_nameandline[<span class="number">0</span>]))</span><br></pre></td></tr></table></figure>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><h4 id="终端中使用"><a href="#终端中使用" class="headerlink" title="终端中使用"></a>终端中使用</h4><ul>
<li>在终端直接执行<code>fzf</code>，搜索到文件后会返回文件的绝对路径</li>
</ul>
<p><img src="../img/fzf-terminal.png" alt=""></p>
<ul>
<li>在终端使用快捷键触发，在任何需要使用路径的地方都可以用</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nvim **&lt;tab&gt;</span><br></pre></td></tr></table></figure>
<ul>
<li>kill命令进程搜索，这个是真的好用</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kill -9 &lt;tab&gt;</span><br></pre></td></tr></table></figure>
<h4 id="在vim中使用"><a href="#在vim中使用" class="headerlink" title="在vim中使用"></a>在vim中使用</h4><ul>
<li>使用<code>:Files</code>命令开始搜索文件，找到后回车打开</li>
</ul>
<p><img src="../img/fzf-vim-file.png" alt=""></p>
<ul>
<li>使用<code>:Rg</code>对文本内容进行模糊搜索，厉害了</li>
</ul>
<p><img src="../img/fzf-vim-text.png" alt=""></p>
<p>然后你可以将这两个命令绑定到快捷键上，这样你就可以享受fzf所带来的便利了。</p>
<h2 id="和ranger配合使用"><a href="#和ranger配合使用" class="headerlink" title="和ranger配合使用"></a>和ranger配合使用</h2><p>ranger是一个终端下的文件浏览器，和它配合使用可以实现文件的寻找并快速跳转。</p>
<p>ranger默认安装完成后没有配置文件，需要执行<code>ranger --copy-config=all</code>来生成默认配置文件。文件路径在<code>~/.config/ranger</code>。现在可以开始添加配置到<em>commands.py</em>，官方的配置你可以在 <a target="_blank" rel="noopener" href="https://github.com/ranger/ranger/wiki/Custom-Commands">这里</a> 找到，但是官方的命令并不好用，所以我进行了一些修改，如下：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># use fzf in ranger</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">fzf_select</span>(<span class="params">Command</span>):</span></span><br><span class="line">    <span class="string">&quot;&quot;&quot;</span></span><br><span class="line"><span class="string">    :fzf_select</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    Find a file using fzf.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    With a prefix argument select only directories.</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">    See: https://github.com/junegunn/fzf</span></span><br><span class="line"><span class="string">    &quot;&quot;&quot;</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">execute</span>(<span class="params">self</span>):</span></span><br><span class="line">        <span class="keyword">import</span> subprocess</span><br><span class="line">        <span class="keyword">import</span> os.path</span><br><span class="line">        <span class="keyword">if</span> self.quantifier:</span><br><span class="line">            <span class="comment"># match only directories</span></span><br><span class="line">            command=<span class="string">&#x27;fdfind --type d --hidden --follow -E &quot;.git&quot; -E &quot;node_modules&quot; . /etc /home/tom | fzf +m&#x27;</span></span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="comment"># match files and directories</span></span><br><span class="line">            command=<span class="string">&#x27;fdfind --hidden --follow -E &quot;.git&quot; -E &quot;node_modules&quot; . /etc /home/tom | fzf +m&#x27;</span></span><br><span class="line">        fzf = self.fm.execute_command(command, universal_newlines=<span class="literal">True</span>, stdout=subprocess.PIPE)</span><br><span class="line">        stdout, stderr = fzf.communicate()</span><br><span class="line">        <span class="keyword">if</span> fzf.returncode == <span class="number">0</span>:</span><br><span class="line">            fzf_file = os.path.abspath(stdout.rstrip(<span class="string">&#x27;\n&#x27;</span>))</span><br><span class="line">            <span class="keyword">if</span> os.path.isdir(fzf_file):</span><br><span class="line">                self.fm.cd(fzf_file)</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                self.fm.select_file(fzf_file)</span><br></pre></td></tr></table></figure>
<p>添加完成之后你就可以通过<code>:fzf_select</code>命令来在ranger中启动fzf查找，并自动跳转了。当然你可以把这个命令绑定到一个快捷键上，通过在<em>rc.conf</em>中添加以下配置。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 将fzf查找绑定到ctrl+f键，最好添加到注释Searching后面，我之前添加到前面没有生效，不知道为什么</span></span><br><span class="line">map &lt;C-f&gt; fzf_select</span><br></pre></td></tr></table></figure>
<blockquote>
<p>目前尚未解决的问题，在nvim中使用Rg进行文本内容搜索时依然只能搜索当前文件夹，并且无法搜索隐藏文件</p>
</blockquote>
<h2 id="问题解决"><a href="#问题解决" class="headerlink" title="问题解决"></a>问题解决</h2><p>2020/9/14, 搜索隐藏文件的问题已解决, 在init.vim中加上以下内容</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">command! -bang -nargs=* Rg</span><br><span class="line">             \ call fzf#vim#grep(</span><br><span class="line">             \ &quot;rg --column --line-number --no-heading --color=always --smart-case --hidden -g &#x27;!**/.git/**&#x27; -- &quot;.shellescape(&lt;q-args&gt;), 1, &lt;bang&gt;0)</span><br><span class="line"><span class="meta"></span></span><br><span class="line"><span class="meta">#</span><span class="bash"> --hidden: 显示隐藏文件</span></span><br><span class="line"><span class="meta">#</span><span class="bash">   -g <span class="string">&#x27;!**/.git/**&#x27;</span>: 排除所有.git文件夹</span></span><br></pre></td></tr></table></figure>

        
            <div class="donate-container">
    <div class="donate-button">
        <button id="donate-button">赞赏</button>
    </div>
    <div class="donate-img-container hide" id="donate-img-container">
        <img id="donate-img" src="" data-src="/img/donate.jpg">
        <p> 感谢鼓励 </p>
    </div>
</div>
        
        <br />
        <div id="comment-container">
        </div>
        <div id="disqus_thread"></div>

        <div id="lv-container">
        </div>

    </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        

        

    </ul>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>  Theme <a target="_blank" rel="noopener" href="https://github.com/aircloud/hexo-theme-aircloud">AirCloud</a></p>
</footer>




<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ["$","$"], ["\\(","\\)"] ],
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            processEscapes: true
        }
    });
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax();
        for (var i = 0; i < all.length; ++i)
            all[i].SourceElement().parentNode.className += ' has-jax';
    });
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/"
    window.isPost = true
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

<script src="/js/index.js"></script>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




</html>
